package de.koller.oceanFramework.thread;

import java.util.Random;

public class PipelineTest {
	
	private PipelineTest() {}
	
	public static void main( String... args ) {
		Pipeline pipeline = new Pipeline(	new PipeTest( 1 ),
											new PipeTest( 2 ),
											new PipeTest( 3 ),
											new PipeTest( 4 ),
											new PipeTest( 5 ),
											new PipeTest( 6 ),
											new PipeTest( 7 ),
											new PipeTest( 8 ) );
		
		System.out.println( "start #1" );
		pipeline.stepPipes();
		
		System.out.println( "start #2" );
		pipeline.stepPipes();
		
		System.out.println( "start #3" );
		pipeline.stepPipes();
	}
	
	private static class PipeTest implements IPipe {
		private final static Random rnd = new Random();
		private final int computeTime;
		private final int id;
		
		public PipeTest( int id ) {
			computeTime = rnd.nextInt( 5000 );
			this.id = id;
		}

		@Override
		public void updateSubStep() {
			try { Thread.sleep( computeTime ); } catch( InterruptedException ex ) {}
			System.out.println( "Pipe #" + id + " fertig" );
		}

		@Override
		public String getName() {
			return "Test";
		}
	
		
	}
	
}
